﻿// HSS.Interlink.CancelCommand.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.html)
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       CancelCommand.cs
// Author:     HSS\gbanta
// Created:    07/16/2011
// Modified:   07/22/2011
// ----------------------------------------------------------------------------
namespace HSS.Interlink
{
	#region Using Directives
	using System;
	using System.Windows.Input;
	#endregion

	#region CancelCommand
	/// <summary>
	/// The CancelCommand
	/// </summary>
	public class CancelCommand : ICommand
	{
		#region Fields
		UploadFileViewModel viewModel;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="uploadFileViewModel">The UploadFileViewModel instance.</param>
		public CancelCommand(UploadFileViewModel uploadFileViewModel)
		{
			this.viewModel = uploadFileViewModel;
		}
		#endregion

		#region ICommand Members
		/// <summary>
		/// Can the command be executed.
		/// </summary>
		/// <param name="parameter">Not used.</param>
		/// <returns>true if the command can execute; otherwise false.</returns>
		public bool CanExecute(object parameter)
		{
			return true;
		}
		/// <summary>
		/// Occurs when the CanExecute state changes.
		/// </summary>
		public event EventHandler CanExecuteChanged;
		void OnCanExecuteChanged()
		{
			var handler = CanExecuteChanged;
			if (null != handler)
				handler(this, EventArgs.Empty);
		}
		/// <summary>
		/// Executes the command.
		/// </summary>
		/// <param name="parameter">Not used.</param>
		public void Execute(object parameter)
		{
			//if (this.CanExecute(parameter))
			this.viewModel.CancelUpload();
		}
		#endregion
	}
	#endregion
}